#include<bits/stdc++.h>
using namespace std;

const int N = 1e2 + 10;
int pos[N];
int l[N], r[N];
int n, m, L, V;
int f1[N], f2[N];
vector<int>g[N];

signed main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	
	int T;
	scanf("%d", &T);
	
	while(T--) {
		memset(pos, 0, sizeof(pos));
		memset(l, 0, sizeof(l));
		memset(r, 0, sizeof(r));

		scanf("%d %d %d %d", &n, &m, &L, &V);
		for(int i = 1; i <= n; ++ i) {
			int p, v, a;
			scanf("%d %d %d", &p, &v, &a);
			if(a > 0) {
				if(v > V) {
					l[i] = p;
					r[i] = L;
				}
				if(v <= V) {
					int s = (double)(V * V - v * v) / 2 / a;
					if(p + s > L)
						continue;
					l[i] = p + s;
					r[i] = L;
				}
			}
			if(a == 0) {
				if(v > V) {
					l[i] = p;
					r[i] = L;
				}
				else
					continue;
			}
			if(a < 0) {
				a = -a;
				if(v <= V)
					continue;
				if(v > V) {
					l[i] = p;
					int s = (double)(v * v - V * V) / 2 / a;
					r[i] = min(p + s, L);
				}
			}
		}

		for(int i = 1; i <= m; ++ i) {
			scanf("%d", pos + i);
		}
		

		int ans1 = 0;
		int ans2 = 0;
		sort(pos + 1, pos + m + 1);

		for(int i = 1; i <= n; ++ i) {
			int u = lower_bound(pos + 1, pos + m + 1, l[i]) - pos;
			int v = lower_bound(pos + 1, pos + m + 1, r[i]) - pos - 1;
			
			if(u <= r[i])
				++ ans1;
			f1[i] = u;
			f2[i] = v;
			
			for(int j = u; j <= v; ++ j) {
				g[j].push_back(i);
			}
		}

		for(int i = 1; i <= m; ++ i) {
			for(auto v : g[i]) {
				if(f2[i] - f1[i] > 1)
					++ ans2;
			}
		}

		cout << ans1 << ' ' << ans2 << endl;
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
